/*==============================================================================
             Copyright (c) 2009 - All rights reserved
================================================================================
File description:

    XMLParser function definition

================================================================================
      Date            Name                    Description of Change
21-Sep-2009  Xiaofeng.Gu                    Written
$HISTORY$
==============================================================================*/
#pragma once

#include "Markup.h"

class CXMLParser
{
public:
	CXMLParser();
	virtual~ CXMLParser();

	void				SetDoc(LPCTSTR szXMLDoc) { m_oMarkup.SetDoc(szXMLDoc); }
	CString				GetDoc();

	void				AddXMLNode(LPCTSTR szNode, LPCTSTR szData = NULL);
	void				AddXMLNode(LPCTSTR szNode, double dData);
	void				AddXMLNode(LPCTSTR szNode, long lData);
	void				AddXMLNode(LPCTSTR szNode, bool bData);

	void				AddChildNode(LPCTSTR szChildNode, LPCTSTR szData = NULL);
	void				AddChildNode(LPCTSTR szChildNode, double dData);
	void				AddChildNode(LPCTSTR szChildNode, long lData);
	void				AddChildNode(LPCTSTR szChildNode, bool bData);

	void				AddAttribute(LPCTSTR szAttrib, LPCTSTR szValue);
	CString				GetAttribute(LPCTSTR szAttrib);

	void				AddType(int iType);
	int					GetType();
	void				AddName(LPCTSTR szName);
	CString				GetName();
	void				AddActive(bool bActive);
	bool				GetActive();

	bool				FindXMLNode(LPCTSTR szNode);
	bool				FindXMLNode(LPCTSTR szNode, CString& strData);
	bool				FindXMLNode(LPCTSTR szNode, double& dData);
	bool				FindXMLNode(LPCTSTR szNode, long& lData);
	bool				FindXMLNode(LPCTSTR szNode, bool& bData);

	bool				FindChildNode(LPCTSTR szChildNode);
	bool				FindChildNode(LPCTSTR szChildNode, CString& strData);
	bool				FindChildNode(LPCTSTR szChildNode, double& dData);
	bool				FindChildNode(LPCTSTR szChildNode, long& lData);
	bool				FindChildNode(LPCTSTR szChildNode, bool& bData);

	void				EndXMLNode();

private:
	CMarkup				m_oMarkup;
};